import { defineConfig } from "vite";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";
import dts from "vite-plugin-dts";
import VitePluginStyleInject from "vite-plugin-style-inject";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // 生成类型文件
    dts({ include: "./src" }),
    // 样式内联到js文件中
    VitePluginStyleInject(),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
    },
  },
  build: {
    lib: {
      entry: resolve(__dirname, "src/index.ts"),
      name: "dongad-danmaku",
      fileName: "index",
    },
    rollupOptions: {
      external: ["vue"],
      output: {
        globals: {
          vue: "Vue",
        },
      },
    },
  },
});
